import type { ElementHiderRuleConfig } from '../../../types/constants'
import { PageHandler } from '../../../lib/page_handler'
import {
  BAIDU_RESULT_MARK_SELECTOR,
  BaiduPageType,
} from '../../../lib/page_handler/platform/baidu/types'
import { ElementSelectorPosition, ElementSelectorType } from '../../../types/constants'
import { ELEMENT_IDENTIFIER_CONFIG } from '../../service/element_identifier/types'
import { addPrefixToConfig } from '../element_config'

function generateAiAnswerSelector(): string {
  return [
    'ai_index',
    'new_baikan_index',
    'wenda_generate',
    'ai_ask',
  ].map(item => `${BAIDU_RESULT_MARK_SELECTOR}[tpl=\'${item}\']`).join(',')
}

function generateHuaJunSoftwareSelector(): string {
  return [
    'https://m.onlinedown.net',
    'http://m.onlinedown.net',
    'http://www.onlinedown.net',
    'https://mip.onlinedown.net',
    'https://soft.onlinedown.net',
    'https://search.onlinedown.net',
  ].map(item => `${BAIDU_RESULT_MARK_SELECTOR}[mu^=\'${item}\']`).join(',')
}

export const BAI_DU_BASE_PAGE_ELEMENT_CONFIG: ElementHiderRuleConfig = {
  [ELEMENT_IDENTIFIER_CONFIG.search.searchTab.id]: {
    hide: false,
    selectorType: ElementSelectorType.Id,
    selector: '#s_tab_inner',
    position: ElementSelectorPosition.TopCenter,
    useCssInjection: false, // 移除 CSS 隐藏规则后，平台 JS 会添加错误的内联样式，所以这里禁用 CSS 注入
    enable: () => {
      const notSupportPages = [
        BaiduPageType.Note,
        BaiduPageType.Index,
        BaiduPageType.Advanced,
        BaiduPageType.More,
      ]
      return !notSupportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.unsupportedSearchTab.id]: {
    hide: false,
    selectorType: ElementSelectorType.Multiple,
    selector: '#wrapper :is(.s_tab_inner, #s_tab_inner) a:is(.s-tab-pic, .s-tab-map, .s-tab-tieba, .s-tab-wenku)',
    position: ElementSelectorPosition.TopCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Web,
        BaiduPageType.News,
        BaiduPageType.Video,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.searchTag.id]: {
    hide: false,
    selectorType: ElementSelectorType.Id,
    selector: '#searchTag',
    position: ElementSelectorPosition.TopCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.ad.brandAd.id]: {
    hide: true,
    selectorType: ElementSelectorType.Id,
    selector: '#top-ad',
    position: ElementSelectorPosition.TopCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.userCenter.id]: {
    hide: false,
    selectorType: ElementSelectorType.Id,
    selector: '#u',
    position: ElementSelectorPosition.TopRight,
    enable: () => {
      const notSupportPages = [
        BaiduPageType.Index,
        BaiduPageType.Advanced,
        BaiduPageType.More,
      ]
      return !notSupportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.tipMessage.id]: {
    hide: false,
    selectorType: ElementSelectorType.Id,
    selector: '#header_top_bar',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.News,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.everyoneSearching.id]: {
    hide: false,
    selectorType: ElementSelectorType.JQuery,
    selector: `${BAIDU_RESULT_MARK_SELECTOR}[tpl=\'recommend_list\']:has(div:contains(大家还在搜))`,
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.base.icon.id]: {
    hide: true,
    selectorType: ElementSelectorType.Multiple,
    selector: `${BAIDU_RESULT_MARK_SELECTOR} i.cos-icon-caret-down-circle-fill, svg[class^=\'_feedback-icon\']`,
    nameZh: '下拉图标',
    nameEn: 'iconDown',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.base.iconTwo.id]: {
    hide: false,
    selectorType: ElementSelectorType.Multiple,
    selector: '[class*=\'source\'] [class^=\'icons-inner\'] [hint-type=\'newBao\'], [class^=\'bao-logo\']:empty',
    nameZh: '保障图标',
    nameEn: 'baoZhang',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.base.iconThree.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '[class*=\'source\'] [class^=\'icons-inner\'] [hint-type=\'baozhang-v\']',
    nameZh: '认证图标',
    nameEn: 'copyright',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.base.iconFour.id]: {
    hide: false,
    selectorType: ElementSelectorType.Complex,
    selector: '[class^=\'open-icon\']:empty',
    nameZh: '开放平台图标',
    nameEn: 'openPlatform',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.baiduWenku.id]: {
    hide: false,
    selectorType: ElementSelectorType.Attribute,
    selector: `${BAIDU_RESULT_MARK_SELECTOR}[tpl=\'jy_wenku_wenshu\']`,
    nameZh: '结果项-百度文库',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.baiduTieBa.id]: {
    hide: false,
    selectorType: ElementSelectorType.Attribute,
    selector: `${BAIDU_RESULT_MARK_SELECTOR}[tpl=\'tieba_general\']`,
    nameZh: '结果项-百度贴吧',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.baiduChinese.id]: {
    hide: false,
    selectorType: ElementSelectorType.Attribute,
    selector: `${BAIDU_RESULT_MARK_SELECTOR}[mu*=\'hanyu.baidu.com\']`,
    nameZh: '结果项-百度汉语',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.baiduBaike.id]: {
    hide: false,
    selectorType: ElementSelectorType.Attribute,
    selector: `${BAIDU_RESULT_MARK_SELECTOR}[mu*=\'baike.baidu.com\']`,
    nameZh: '结果项-百度百科',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.baiduWeather.id]: {
    hide: false,
    selectorType: ElementSelectorType.Attribute,
    selector: `${BAIDU_RESULT_MARK_SELECTOR}[tpl=\'weather_forecast_san\']`,
    nameZh: '结果项-百度天气',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.baiduJiahao.id]: {
    hide: false,
    selectorType: ElementSelectorType.Attribute,
    selector: `${BAIDU_RESULT_MARK_SELECTOR}[tpl=\'guanfanghao_san\']`,
    nameZh: '结果项-百家号',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.ai.aiAnswer.id]: {
    hide: false,
    selectorType: ElementSelectorType.Multiple,
    selector: generateAiAnswerSelector(),
    nameZh: '结果项-AI 回答',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.ai.aiAgent.id]: {
    hide: false,
    selectorType: ElementSelectorType.Multiple,
    selector: `${BAIDU_RESULT_MARK_SELECTOR}[tpl=\'ai_agent_distribute\'], ${BAIDU_RESULT_MARK_SELECTOR}[tpl=\'ai_agent_qa_recommend\']`,
    nameZh: '结果项-智能体回复',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.featuredNotes.id]: {
    hide: false,
    selectorType: ElementSelectorType.Attribute,
    selector: `${BAIDU_RESULT_MARK_SELECTOR}[tpl=\'note_lead\']`,
    nameZh: '结果项-精选笔记',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.developerSearch.id]: {
    hide: false,
    selectorType: ElementSelectorType.Attribute,
    selector: `${BAIDU_RESULT_MARK_SELECTOR}[tpl=\'kaifa_pc_blog_weak_no_border\']`,
    nameZh: '结果项-开发者搜索',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.huiLife.id]: {
    hide: false,
    selectorType: ElementSelectorType.Multiple,
    selector: `${BAIDU_RESULT_MARK_SELECTOR}[tpl=\'jy_bdb_in_store_service_san\'], ${BAIDU_RESULT_MARK_SELECTOR}[tpl=\'jy_bdb_in_store_service_2nd\']`,
    nameZh: '结果项-惠生活',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.quickDownload.id]: {
    hide: false,
    selectorType: ElementSelectorType.Attribute,
    selector: `${BAIDU_RESULT_MARK_SELECTOR}[tpl=\'pc-soft-accurate\']`,
    nameZh: '结果项-极速下载',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.bingDictionary.id]: {
    hide: false,
    selectorType: ElementSelectorType.Attribute,
    selector: `${BAIDU_RESULT_MARK_SELECTOR}[mu*=\'cn.bing.com\/dict\']`,
    nameZh: '结果项-必应词典',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.kingDictionary.id]: {
    hide: false,
    selectorType: ElementSelectorType.Attribute,
    selector: `${BAIDU_RESULT_MARK_SELECTOR}[mu*=\'www.iciba.com\']`,
    nameZh: '结果项-金山词霸',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.video.id]: {
    hide: false,
    selectorType: ElementSelectorType.Attribute,
    selector: `${BAIDU_RESULT_MARK_SELECTOR}[tpl=\'yl-vd-basis\']`,
    nameZh: '结果项-视频',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.shortVideo.id]: {
    hide: false,
    selectorType: ElementSelectorType.Attribute,
    selector: `${BAIDU_RESULT_MARK_SELECTOR}[tpl=\'short_video\']`,
    nameZh: '结果项-短视频',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.softwarePark.id]: {
    hide: false,
    selectorType: ElementSelectorType.Multiple,
    selector: generateHuaJunSoftwareSelector(),
    nameZh: '结果项-软件园',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.ad.contentAd.id]: {
    show: false,
    hide: true,
    selectorType: ElementSelectorType.JQuery,
    selector: 'div[id^=\'content_left\'] div:has([data-tuiguang]:contains(广告), a:contains(广告):not(:has(*)))',
    position: ElementSelectorPosition.MiddleCenter,
    listen: true,
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.selectedSearch.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#wrapper_wrapper .selected-search-box',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.rightAside.id]: {
    hide: true,
    selectorType: ElementSelectorType.Id,
    selector: '#content_right',
    position: ElementSelectorPosition.MiddleRight,
    enable: () => {
      const supportPages = [
        BaiduPageType.Web,
        BaiduPageType.News,
        BaiduPageType.Video,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.jumpSearch.id]: {
    hide: false,
    selectorType: ElementSelectorType.Id,
    selector: '#gotoPage',
    position: ElementSelectorPosition.BottomCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.News,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.relatedSearches.id]: {
    hide: false,
    selectorType: ElementSelectorType.Complex,
    selector: 'div:has(> #rs_new)',
    position: ElementSelectorPosition.BottomCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Web,
        BaiduPageType.News,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.searchPagination.id]: {
    hide: false,
    selectorType: ElementSelectorType.Id,
    selector: '#page',
    position: ElementSelectorPosition.BottomCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Web,
        BaiduPageType.News,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.footer.id]: {
    hide: false,
    selectorType: ElementSelectorType.Id,
    selector: '#foot',
    position: ElementSelectorPosition.BottomCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Web,
        BaiduPageType.News,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.assistantMode.id]: {
    hide: false,
    selectorType: ElementSelectorType.Class,
    selector: '.s_side_wrapper',
    position: ElementSelectorPosition.BottomRight,
    enable: () => {
      const supportPages = [
        BaiduPageType.Video,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
}

export const BAI_DU_NOTE_PAGE_ELEMENT_CONFIG: ElementHiderRuleConfig = {
  [ELEMENT_IDENTIFIER_CONFIG.search.searchTab.id]: {
    hide: false,
    selectorType: ElementSelectorType.Class,
    selector: '.s_tab_inner',
    position: ElementSelectorPosition.TopCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Note,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.unsupportedSearchTab.id]: {
    hide: false,
    selectorType: ElementSelectorType.Multiple,
    selector: '#page-hd .s_tab_inner a:is(.s-tab-pic, .s-tab-map, .s-tab-tieba, .s-tab-wenku)',
    position: ElementSelectorPosition.TopCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Note,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.tipMessage.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#page-hd .note-number-tip-pc',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Note,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
}

export const BAI_DU_INDEX_PAGE_ELEMENT_CONFIG: ElementHiderRuleConfig = {
  [ELEMENT_IDENTIFIER_CONFIG.default.headerNav.id]: {
    hide: false,
    selectorType: ElementSelectorType.Id,
    selector: '#s-top-left',
    position: ElementSelectorPosition.TopLeft,
    enable: () => {
      const supportPages = [
        BaiduPageType.Index,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.userCenter.id]: {
    hide: false,
    selectorType: ElementSelectorType.Id,
    selector: '#u1',
    position: ElementSelectorPosition.TopRight,
    enable: () => {
      const supportPages = [
        BaiduPageType.Index,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.decoration.id]: {
    hide: false,
    selectorType: ElementSelectorType.Complex,
    selector: '#wrapper #head_wrapper #lg > img[id^=\'s_lg_img\']',
    nameZh: '装饰图片',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Index,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.ai.aiTool.id]: {
    hide: false,
    selectorType: ElementSelectorType.Id,
    selector: '#chat-input-extension',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Index,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.baiduHotSearch.id]: {
    hide: false,
    selectorType: ElementSelectorType.Id,
    selector: '#s-hotsearch-wrapper',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Index,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.ai.smartTool.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#s_wrap [tpl=\'ai-tools-panel\']',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Index,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.ai.smartToolTitle.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#s_wrap [tpl=\'ai-tools-panel\'] [class^=\'top-bar\']',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Index,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.footer.id]: {
    hide: false,
    selectorType: ElementSelectorType.Id,
    selector: '#bottom_layer',
    position: ElementSelectorPosition.BottomCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Index,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.assistantMode.id]: {
    hide: false,
    selectorType: ElementSelectorType.Id,
    selector: '#s_side_wrapper',
    position: ElementSelectorPosition.BottomRight,
    enable: () => {
      const supportPages = [
        BaiduPageType.Index,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
}

export const BAI_DU_ADVANCED_PAGE_ELEMENT_CONFIG: ElementHiderRuleConfig = {
  [ELEMENT_IDENTIFIER_CONFIG.default.userCenter.id]: {
    hide: false,
    selectorType: ElementSelectorType.Id,
    selector: '#tl',
    nameZh: '标题与登录',
    position: ElementSelectorPosition.TopCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Advanced,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.footer.id]: {
    hide: false,
    selectorType: ElementSelectorType.Id,
    selector: '#ft',
    position: ElementSelectorPosition.BottomCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.Advanced,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
}

export const BAI_DU_MORE_PAGE_ELEMENT_CONFIG: ElementHiderRuleConfig = {
  [ELEMENT_IDENTIFIER_CONFIG.default.input.id]: {
    hide: false,
    selectorType: ElementSelectorType.Id,
    selector: '#head',
    position: ElementSelectorPosition.TopCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.More,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.newArrivals.id]: {
    hide: false,
    selectorType: ElementSelectorType.JQuery,
    selector: '#content h3:contains(新上线), #content h3:contains(新上线) ~ .con:not(#content h3:contains(搜索服务) ~ .con)',
    nameZh: '新上线',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.More,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.service.searchService.id]: {
    hide: false,
    selectorType: ElementSelectorType.JQuery,
    selector: '#content h3:contains(搜索服务), #content h3:contains(搜索服务) ~ .con:not(#content h3:contains(导航服务) ~ .con)',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.More,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.service.navigationService.id]: {
    hide: false,
    selectorType: ElementSelectorType.JQuery,
    selector: '#content h3:contains(导航服务), #content h3:contains(导航服务) ~ .con:not(#content h3:contains(社区服务) ~ .con)',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.More,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.service.communityService.id]: {
    hide: false,
    selectorType: ElementSelectorType.JQuery,
    selector: '#content h3:contains(社区服务), #content h3:contains(社区服务) ~ .con:not(#content h3:contains(游戏娱乐) ~ .con)',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.More,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.service.gameEntertainment.id]: {
    hide: false,
    selectorType: ElementSelectorType.JQuery,
    selector: '#content h3:contains(游戏娱乐), #content h3:contains(游戏娱乐) ~ .con:not(#content h3:contains(移动服务) ~ .con)',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.More,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.service.mobileService.id]: {
    hide: false,
    selectorType: ElementSelectorType.JQuery,
    selector: '#content h3:contains(移动服务), #content h3:contains(移动服务) ~ .con:not(#content h3:contains(站长与开发者服务) ~ .con)',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.More,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.service.developerService.id]: {
    hide: false,
    selectorType: ElementSelectorType.JQuery,
    selector: '#content h3:contains(站长与开发者服务), #content h3:contains(站长与开发者服务) ~ .con:not(#content h3:contains(软件工具) ~ .con)',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.More,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.service.softwareTools.id]: {
    hide: false,
    selectorType: ElementSelectorType.JQuery,
    selector: '#content h3:contains(软件工具), #content h3:contains(软件工具) ~ .con',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.More,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.footer.id]: {
    hide: false,
    selectorType: ElementSelectorType.Class,
    selector: '.footer',
    position: ElementSelectorPosition.BottomCenter,
    enable: () => {
      const supportPages = [
        BaiduPageType.More,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as BaiduPageType)
    },
  },
}

/**
 * 所有配置
 */
export const BAI_DU_WEB_ELEMENT_CONFIG: ElementHiderRuleConfig = {
  ...addPrefixToConfig(BAI_DU_BASE_PAGE_ELEMENT_CONFIG, 'base'),
  ...addPrefixToConfig(BAI_DU_NOTE_PAGE_ELEMENT_CONFIG, 'note'),
  ...addPrefixToConfig(BAI_DU_INDEX_PAGE_ELEMENT_CONFIG, 'index'),
  ...addPrefixToConfig(BAI_DU_ADVANCED_PAGE_ELEMENT_CONFIG, 'advanced'),
  ...addPrefixToConfig(BAI_DU_MORE_PAGE_ELEMENT_CONFIG, 'more'),
}
